package cn.tannn.ops.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 云厂商名字
 *
 * @author <a href="https://t.tannn.cn/">tan</a>
 * @version V1.0
 * @date 2024/8/29 下午12:10
 */
@AllArgsConstructor
@Getter
public enum CloudEnums {

    /**
     * 阿里
     */
    ALI("ali", "阿里"),
    /**
     * 腾讯
     */
    TENCENT("tencent", "腾讯"),
    /**
     * 华为云
     */
    HUAWEI("huawei", "华为云");

    private final String cloud;
    private final String name;

    /**
     * 获取枚举实例
     */
    public static CloudEnums fromName(String name) {
        for (CloudEnums signType : CloudEnums.values()) {
            if (Objects.equals(name, signType.getName())) {
                return signType;
            }
        }
        throw new IllegalArgumentException();
    }



    /**
     * to map
     * @return {cloud:xx,app:yy}
     */
    public static List<Map<String,String>> toMap(){
        List<Map<String, String>> maps = new ArrayList<>();
        for (CloudEnums value : CloudEnums.values()) {
            maps.add(Map.of("cloud",value.getCloud().toUpperCase(),"name",value.getName()));
        }
        return maps;
    }
}
